Fix: Pundit adapter blindly ignores existing pundit_user definition #2467
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per the pundit readme, there are instances where I need to provide additional context about the user. I do this by defining pundit_user, however the pundit rails_admin adapter ignores this and replaces it with it's own pointing at current_user. This breaks policies that rely on the additional context.
This patch addresses this.
In addition to this I have another issue with the pundit adapter, and I'd like to include some fixes for it as well, but before just doing them I'd like to see if there's a good reason why things have been done the way they are.
Typically the method name for checking with pundit for "can I do X" will be suffixed with a "?". Currently the pundit adapter does not do this.
I see 2 problems with this:
alias_method :index, :index?
) - a minor incovenienceI'd like to put a patch together that basically either prefixes the methods with rails_admin, or works more like sudosu/rails_admin_pundit where it runs through a specific method, which in turn can use a case statement.
I'd appreciate any input on that before I write a patch and start depending on it.